<template>
	<view class="container">
		<uni-forms >
			<uni-forms-item label="姓名" name="name">
				<uni-easyinput type="text" v-model="telephone" placeholder="请输入姓名" />
			</uni-forms-item>
			<uni-forms-item label="密码" name="password">
				<uni-easyinput type="password" v-model="password" placeholder="请输入姓名" />
			</uni-forms-item>
		</uni-forms>
		<button @click="reg" type='primary'>注册</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				telephone:'',
				password:''
			}
		},
		methods: {
			reg(){
				uni.request({
					url: 'http://localhost:8090/foodapp/user/register',
					method: 'POST',
					data: {
						telephone:this.telephone,
						password:this.password
					},
					success: res => {
						if(res.data.success){
							uni.showToast({
								title: '成功',
								icon: 'none'
							});
							uni.navigateBack({
						        delta:1
							})
						}else{
							uni.showToast({
								title: '失败',
								icon: 'none'
							});
						}
					},
					fail: () => {},
					complete: () => {}
				});
			}
		},
		onLoad: () => {
			uni.onTabBarMidButtonTap(function(e){
				console.log(e)
				
			})
		}
	}
</script>

<style>
	.container {
		padding: 20px;
		font-size: 14px;
		line-height: 24px;
	}
</style>
